import 'package:flutter/material.dart';

class Page2 extends StatefulWidget {
  final title;
  Page2({Key key, this.title = 'Page2'}) : super(key: key);

  _Page2State createState() => _Page2State();
}

class _Page2State extends State<Page2> {
  @override
  Widget build(BuildContext context) {
    /* 接收参数 */
    final params = ModalRoute.of(context).settings.arguments;
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: ListView(
        children: <Widget>[
          ListTile(
            title: Text('我是Page2页面,$params'),
            onTap: () {
              Navigator.of(context).pushNamed('/page3');
              // Navigator.push(
              //   context,
              //   new MaterialPageRoute(
              //     builder: (BuildContext context) => Page3(),
              //   ),
              // );
            },
          ),
          FlatButton(
            onPressed: () {
              // 返回值给上一级页面
              Navigator.of(context).pop('child');
            },
            child: Text('返回'),
          )
        ],
      ),
    );
  }
}
